<?php

/**
 * LEAGUEMan
 *
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
class Teamresult
{
    /** @var object project */
    public $project;
    /** @var object round */
    public $team;
    /** @var int mode */
    public $mode;


    public function __construct()
    {
        $this->project = null;
        $this->team = null;
        $this->mode = 0;
    }

    public function setProject(LM_Table_Project $project)
    {
        $this->project = $project;
    }

    public function setTeam(LM_Table_Team $team)
    {
        $this->team = $team;
    }

    public function loadProject($id)
    {
        $this->project = LM::getLMTable("Project");
        $this->project->load($id);
    }

    public function loadTeam($id)
    {
        $this->team = LM::getLMTable("Team");
        $this->team->load($id);
    }

    public function setMode($mode)
    {
        $this->mode = $mode;
    }

    public function getTeam()
    {
        return $this->team;
    }

    public function getProject()
    {
        return $this->project;
    }

    public function getResults()
    {
        $matchtable = LM::getLMTable("Match");
        $matchtable->filterbyProject($this->project->getID());
        $matchtable->filterbyTeam($this->team->getID(), $this->mode);

        return $matchtable->getRows();
    }

}